
import store from '@/store'
import Base64 from 'crypto-js/enc-base64'
import Utf8 from 'crypto-js/enc-utf8'
class Token {
  getToken () {
    return store.state.token
  }

  getID () {
    const token = this.getToken()
    const tokenArray = token.split('.')
    const tokenData = tokenArray[1]
    const data = Base64.parse(tokenData)
    const tokenObjStr = Utf8.stringify(data)
    const tokenObj = JSON.parse(tokenObjStr)
    return tokenObj.i
  }
}

export default new Token()
